.class Dinosaur
.field name Ljava/lang/String;
.field carnivorous Z
.field color Ljava/lang/String;

.method <init>()V
	aload_0
	invokespecial java/lang/Object/<init> ()V
	return
.end method

.method <init>(Ljava/lang/String;Z)V
	aload_0
	;;invokespecial java/lang/Object/<init> ()V
	invokespecial Dinosaur/<init> ()V
	aload_0
	aload_1
	putfield Dinosaur/name Ljava/lang/String;
	aload_0
	iload_2
	putfield Dinosaur/carnivorous Z
	return
.end method

.method setColor(Ljava/lang/String;)V
	aload_0
	aload_1
	putfield Dinosaur/color Ljava/lang/String;
	return
.end method                                       

.method setColor(Ljava/awt/Color;)V
	aload_0                                                             
	aload_1                                                              
	invokevirtual java/awt/Color/toString()Ljava/lang/String;
	invokespecial Dinosaur/setColor(Ljava/lang/String;)V
	return
.end method
                                                                         
.end class                                                                 


.class Velociraptor
.super Dinosaur

.method <init>()V
	aload_0
	ldc "Raptor"
	bipush 1
	invokespecial Dinosaur/<init> (Ljava/lang/String;Z)V
	return
.end method

.end class


.class RightTriangle
.field a F
.field b F

.method <init>(FF)V
	aload_0
	invokespecial java/lang/Object/<init> ()V
	
	;; initializing fields
	aload_0
	fload_1
	putfield RightTriangle/a F
	aload_0
	fload_2
	putfield RightTriangle/b F
	
	return
.end method

.method hypotenuse()F
	aload_0
	dup		;the "this" at stack bottom is for the invoke of sumOfSquares()
	getfield RightTriangle/a F
	aload_0
	getfield RightTriangle/b F
	invokevirtual RightTriangle/sumOfSquares (FF)F
	f2d
	invokestatic java/lang/Math/sqrt(D)D
	d2f
	freturn
.end method

.method sumOfSquares(FF)F
	fload_1
	dup
	fmul
	fload_2
	dup
	fmul
	fadd
	freturn
.end method

.end class

.class ArrayDemo

.method static demo()Ljava/lang/String;
	iconst_5
	anewarray java/lang/String	;array[5] created, all elements are null
	
	dup
	iconst_0
	ldc "Hello"
	aastore
	
	dup
	iconst_1
	ldc "World"
	aastore		;now array[5]=["Hello","World",null,null,null]
	
	dup
	iconst_0
	aaload
	
	areturn		;should return "World"
.end method

.end class
